package com.topnav.mc.uitls;

import com.js.lib.cache.SysCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


/**
 * 说明：任务同步锁
 * @类名: TaskLockUtil
 *
 * @author   kenny
 * @Date	 2020年8月25日下午1:39:48
 */
@Component
public class TaskLockUtil {
	@Resource
	private SysCache sysCache;
	
	public void lock(String key){
		sysCache.set(key, 1, 24*60*60L);
	}
	public void lock(String key,long sec){
		sysCache.set(key, 1, sec);
	}
	
	public void unLock(String key){
		sysCache.remove(key);
	}
	
	public boolean isLock(String key){
		return sysCache.get(key)!=null;
	}
}
